//获取本地数据
function getData(key) {
    return localStorage.getItem(key)
    ? JSON.parse(localStorage.getItem(key))
    : []
}
//删除本地数据
function delData(key, index) {
    let data = getData(key)
    data.splice(index, 1)
    setData(key, data)
}
//设置更新本地数据
function setData(key, data) {
    localStorage.setItem(key, JSON.stringify(data))
}
//追加本地数据
function addData(key, data = {}) {
    let localData = getData(key)
    localData.unshift(data)
    setData(key, localData)
}
